package com.jyu.hakkatranslation.controller;

import com.jyu.hakkatranslation.pojo.WordEntry;
import com.jyu.hakkatranslation.service.SearchService;
import com.jyu.hakkatranslation.vo.entryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class SearchController {
    @Autowired
    SearchService searchService;
    @GetMapping("/search")
    public String Search(@RequestParam("item") String item,
                         @RequestParam("place") String place,
                         @RequestParam("word") String word, Model model){
        entryVo entryVo = new entryVo();
        entryVo.setItem(item);
        entryVo.setPlace(place);
        entryVo.setWord(word);
        List<WordEntry> wordEntries = searchService.searchWordEntry(entryVo);
        model.addAttribute("wordEntries",wordEntries);
        System.out.println(item);
        System.out.println(place);
        System.out.println(word);
        System.out.println(wordEntries);
        return "Result";

    }
}
